import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import SelectCommon from 'code/Core/Common/SelectCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 绝望怒吼
 **/
export default class ZS_HowlOfDespair extends AbilityBase {
    static instance: ZS_HowlOfDespair;
    buffType: AppBuffType = {
        id: 'buff_ZS_HowlOfDespair',
        art: this.art,
        name: this.abilityName,
        ubertip: '最大生命值与生命回复速度得到强化',
        dur: 10,
        attribute: {},
        targetAttach: 'chest',
        targetArt: 'Abilities\\Spells\\Other\\Volcano\\VolcanoMissile.mdl',
    };
    constructor(id: string = 'Ajwh') {
        super(id);
        ZS_HowlOfDespair.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let us = SelectCommon.getAllyUnitInRange(source, 550);
        let lv = this.getAbilityLevel(source);
        let p = (100 - GetUnitStatePercent(source, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)) / 100;
        for (let u of us) {
            // let buff = BuffUtil.addBuff(u, this.buffType.id, source);
            // buff.attribute.life_p = p * (0.4 + 0.05 * lv);
            // buff.attribute.生命恢复增强 = 0.5 + p * 4 * lv;
            BuffCommon.addBuff({
                target: u,
                caster: source,
                buffTypeId: this.buffType.id,
                ablityId: this.id,
                attribute: {
                    life_p: p * (0.4 + 0.05 * lv),
                    生命恢复增强: 0.5 + p * 4 * lv,
                },
            });
        }
        DestroyEffect(AddSpecialEffectTarget('Abilities\\Spells\\NightElf\\BattleRoar\\RoarCaster.mdl', source, 'origin'));
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
